/*
 *--------------------------------------------------------------------------
 *   File Name:	boot.c
 * 
 *      Author:	Zhao Yanbai [zhaoyanbai@126.com]
 * 			Wed Dec 30 21:55:29 2009
 * 
 * Description:	none
 * 
 *--------------------------------------------------------------------------
 */


#include<system.h>
#include<multiboot.h>
void CheckKernel(unsigned long addr, unsigned long magic)
{

	int i, mmapCount;
	pmmapItem pMPI;

	pMultiBootInfo pMBI = (pMultiBootInfo) addr;

	if(magic != MULTIBOOT_BOOTLOADER_MAGIC)
	{
		printk("Your boot loader does not support multiboot.\n");
		while(1);
	}

	if( (pMBI->flags & 0x47) != 0x47)
	{
		printk("Kernel Need More Information\n");
		while(1);
	}


	
	system.mmap_addr= pMBI->mmap_addr;
	system.mmap_size= pMBI->mmap_length;
	
	system.mm_lower	= pMBI->mem_lower;
	system.mm_upper	= pMBI->mem_upper;

	// 算出物理内存的大小
	system.mm_size	= 0x100000 + (system.mm_upper<<10);

	system.boot_device	= pMBI->boot_device;
	system.cmdline		= (char *)pMBI->cmdline;

#if 1
	printk("mem size: %d KB\n", system.mm_size>>10);
	printk("boot device: %x\n", (unsigned int)system.boot_device);
	printk("CmdLine: %s\n", system.cmdline);

	mmapCount = system.mmap_size/sizeof(mmapItem);
	printk("mmap count: %d\n", mmapCount);
	pMPI	= (pmmapItem) system.mmap_addr;

	for(i=0; i<mmapCount; i++, pMPI++)
	{
		printk("size: %x ", pMPI->size);
		printk("addr low: %x ", pMPI->base_addr_low);
		printk("addr high: %x ", pMPI->base_addr_high);
		printk("len low:%x ", pMPI->length_low);
		printk("len high:%x ", pMPI->length_high);
		printk("type:%x\n", pMPI->type);
	}
#endif

	// 算出内存的大小
	
}
